// 笔试强训day24:最大子矩阵

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n = 0; cin >> n;
    vector<vector<int>> nums(n + 1, vector<int>(n + 1, 0));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> nums[i][j];
            nums[i][j] += nums[i - 1][j];
        }
    }

    int maxsum = -128;
    for(int u = 0; u <= n - 1; u++)//上边界-1
    {
        for(int l = u + 1; l <= n; l++)//下边界
        {
            int pre = 0, cur = 0;
            for(int j = 1; j <= n; j++)
            {
                cur = nums[l][j] - nums[u][j];
                if(pre > 0)
                    cur += pre;

                if(cur > maxsum)
                    maxsum = cur;
                
                pre = cur;
            }
        }
    }
    cout << maxsum << endl;
}